package com.changdu.seatunnel.admin.pojo;

import java.util.List;
import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

import lombok.Data;

@Data
public class SyncConfigGenerate {
	private Long id;
    private SourceConfig sourceConfig;
    private TargetConfig targetConfig;
    private List<TableMapping> tableMappings;
    private KafkaConfig kafkaConfig;
    
    public void setKafkaConfig(KafkaConfig kafkaConfig) {
    	if (Objects.isNull(kafkaConfig)) return; 
    	
    	if (StringUtils.isNotEmpty(kafkaConfig.getKafkaTopic())) {
    		if (Objects.isNull(kafkaConfig.getKafkaPartition())) {
    			kafkaConfig.setKafkaPartition(3);
    		}
    		this.kafkaConfig = kafkaConfig;
    	}
    }
    
    public boolean kafkaConfigNotEmpty() {
    	return Objects.nonNull(kafkaConfig) && StringUtils.isNotBlank(kafkaConfig.getKafkaTopic());
    }
    
}